package cn.tac.framework.dao;


import cn.tac.framework.core.pojo.ErrorCode;
import cn.tac.framework.core.pojo.ErrorMessage;

import java.util.HashMap;

/**
 * 仓库层相关错误码 - range[100,149]
 *
 * @author : tac
 * @since : 2017/7/14
 */
public enum DaoErrorCode implements ErrorCode {
    INSERT_ERROR("100"),
    UPDATE_ERROR("101"),
    DELETE_ERROR("102"),
    SELECT_ERROR("103"),

    ;

    private String code;
    DaoErrorCode(String code) {
        this.code = code;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage(Object... args) {
        return errorMessage.getErrorMessage(this, args);
    }


    private static HashMap<ErrorCode, String> zh = new HashMap<>();
    static {
        zh.put(DaoErrorCode.INSERT_ERROR, "新增数据失败");
        zh.put(DaoErrorCode.DELETE_ERROR, "删除数据失败");
        zh.put(DaoErrorCode.SELECT_ERROR, "获取数据失败");
        zh.put(DaoErrorCode.UPDATE_ERROR, "更新数据失败");
    }
    private static ErrorMessage errorMessage = new ErrorMessage(zh);
}
